// ==UserScript==
// @name         Github 文档添加 star
// @namespace    https://gitee.com/cn-src/browser-plugin-support
// @version      0.1
// @description  码云批量同步 github 项目
// @author       cn-src
// @match        https://github.com/*
// @grant        none
// @require      https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
// ==/UserScript==

(function () {
    var githubA = $('a[href^="https://github.com/"]');
    $.each(githubA, function (i,a) {
        var href = $(a).attr("href");
        if (href.match('https://github.com/.+/.+')){
            var urlMatches = new RegExp('https://github.com/(.+)/(.+)').exec(href);
            $(a).before('<img alt="GitHub stars" src="https://img.shields.io/github/stars/' + urlMatches[1] + '/' + urlMatches[2] +'.svg?style=social">')
        }
    });
})()
